package com.lehecai.core.api.message;

import com.lehecai.core.IntegerBeanLabelItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created by zhangzq on 14-4-11.
 */
public class ReceiveType extends IntegerBeanLabelItem {

    private static final Logger logger = LoggerFactory.getLogger(ReceiveType.class.getName());
    private static final long serialVersionUID = -1;

    private static List<ReceiveType> _items = new ArrayList<ReceiveType>();
    private static List<ReceiveType> items;

    protected ReceiveType(String name, int value) {
        super(ReceiveType.class.getName(), name, value);
        _items.add(this);
    }

    public static ReceiveType getItem(int value){
        try {
            return (ReceiveType) ReceiveType.getResult(ReceiveType.class.getName(), value);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return null;
        }
    }

    /**
     * @return
     */
    public static List<ReceiveType> getItems() {
        return items;
    }
    public static final ReceiveType ALL = new ReceiveType("全体用户", 1);
    public static final ReceiveType USERID = new ReceiveType("用户名方式", 2);
    //以后开展用
    static {
        synchronized (_items) {
            items = Collections.unmodifiableList(_items);
        }
    }
}
